﻿using System.Text.Json.Serialization;

namespace DoNet.Bpmn.Core.Vo
{
    public class BpmnNodeVo
    {
        [JsonPropertyName("id")]
        public long Id { get; set; }

        [JsonPropertyName("confId")]
        public long ConfId { get; set; }

        [JsonPropertyName("nodeId")]
        public string NodeId { get; set; } = string.Empty;

        [JsonPropertyName("nodeType")]
        public int NodeType { get; set; }
        [JsonPropertyName("isParallel")]
        public bool? IsParallel { get; set; }
        [JsonPropertyName("isDynamicCondition")]
        public bool? IsDynamicCondition { get; set; }
        [JsonPropertyName("aggregationNode")]
        public bool? AggregationNode { get; set; }
        [JsonPropertyName("nodeProperty")]
        public int? NodeProperty { get; set; }

        [JsonPropertyName("nodePropertyName")]
        public string NodePropertyName { get; set; } = string.Empty;

        [JsonPropertyName("nodeFrom")]
        public string NodeFrom { get; set; } = string.Empty;

        private string _nodeFroms = string.Empty;
        [JsonPropertyName("nodeFroms")]
        public string NodeFroms
        {
            get { return _nodeFroms; }
            set
            {
                _nodeFroms = value;
                if (!string.IsNullOrEmpty(value))
                {
                    // 当设置 NodeFroms 时，自动更新 PrevId
                    PrevId = new List<string>(value.Split(','));
                }
            }
        }

        [JsonPropertyName("prevId")]
        private List<string> _prevId = new List<string>();
        public List<string> PrevId
        {
            get { return _prevId; }
            set
            {
                _prevId = value;
                if (_prevId != null && _prevId.Count > 0)
                {
                    // 当设置 PrevId 时，自动更新 NodeFroms
                    NodeFroms = string.Join(",", _prevId);
                }
            }
        }

        [JsonPropertyName("batchStatus")]
        public int BatchStatus { get; set; }

        [JsonPropertyName("approvalStandard")]
        public int ApprovalStandard { get; set; }

        [JsonPropertyName("nodeName")]
        public string NodeName { get; set; } = string.Empty;

        [JsonPropertyName("nodeDisplayName")]
        public string NodeDisplayName { get; set; } = string.Empty;

        [JsonPropertyName("annotation")]
        public string Annotation { get; set; } = string.Empty;

        [JsonPropertyName("isDeduplication")]
        public int IsDeduplication { get; set; }

        [JsonPropertyName("deduplicationExclude")]
        public bool DeduplicationExclude { get; set; }

        [JsonPropertyName("isSignUp")]
        public int IsSignUp { get; set; }

        [JsonPropertyName("orderedNodeType")]
        public int? OrderedNodeType { get; set; }

        [JsonPropertyName("remark")]
        public string Remark { get; set; } = string.Empty;

        [JsonPropertyName("isDel")]
        public int IsDel { get; set; }

        [JsonPropertyName("createUser")]
        public string CreateUser { get; set; } = string.Empty;

        [JsonPropertyName("createTime")]
        public DateTime? CreateTime { get; set; }

        [JsonPropertyName("updateUser")]
        public string UpdateUser { get; set; } = string.Empty;

        [JsonPropertyName("updateTime")]
        public DateTime? UpdateTime { get; set; }

        //===============>>ext fields<<===================

        [JsonPropertyName("nodeTo")]
        public List<string> NodeTo { get; set; } = new List<string>();

        [JsonPropertyName("property")]
        public BpmnNodePropertysVo? Property { get; set; }

        [JsonPropertyName("params")]
        public BpmnNodeParamsVo? Params { get; set; }

        [JsonPropertyName("buttons")]
        public BpmnNodeButtonConfBaseVo? Buttons { get; set; }

        [JsonPropertyName("templateVos")]
        public List<BpmnTemplateVo> TemplateVos { get; set; } = new List<BpmnTemplateVo>();

        [JsonPropertyName("approveRemindVo")]
        public BpmnApproveRemindVo? ApproveRemindVo { get; set; }

        //===============>>third party processs service<<===================

        [JsonPropertyName("conditionsUrl")]
        public string ConditionsUrl { get; set; } = string.Empty;

        [JsonPropertyName("formCode")]
        public string FormCode { get; set; } = string.Empty;

        [JsonPropertyName("isOutSideProcess")]
        public int? IsOutSideProcess { get; set; }

        [JsonPropertyName("isLowCodeFlow")]
        public int? IsLowCodeFlow { get; set; }

        [JsonPropertyName("lfFieldControlVOs")]
        public List<LFFieldControlVo> LfFieldControlVOs { get; set; } = new List<LFFieldControlVo>();

        [JsonPropertyName("fromNodes")]
        public List<BpmnNodeVo> FromNodes { get; set; } = new List<BpmnNodeVo>();

        [JsonPropertyName("elementId")]
        public string ElementId { get; set; } = string.Empty;
    }
}
